<?php
class UserMenuWidget extends CWidget
{
    public $cssFile,$jsFile,$class;
    public $items=array();

    protected function registerClientScript()
    {
        if(isset($this->cssFile) || isset($this->jsFile)){
            $cs = Yii::app()->clientScript;
        }
        if(isset($this->cssFile))
        {
            $cs->registerCssFile(Yii::app()->baseUrl.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.$this->cssFile);
        }
        if(isset($this->jsFile))
        {
            $cs->registerScriptFile(Yii::app()->baseUrl.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.$this->jsFile);
        }
        if($this->controller->id === 'backend'){
            $cs->registerScript('tb-dropdown',"$('.dropdown-toggle').dropdown();");
        }

    }

    public function init()
    {
        if($this->cssFile === null)
        {
            $file = 'css'.DIRECTORY_SEPARATOR.'usermenu.css';
            $this->cssFile = Yii::app()->getAssetManager()->publish($file);
        }
        else
        {
            $this->registerClientScript();
        }


        parent::init();
    }


    public function run()
    {


    }
}
